package com.yogee.topseller.view;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.View;

/**
 * 背景园
 * 
 * @auathor ${XiaoJianghong}
 * @date 2017/3/22.
 */

public class ArcView extends View {

    private Paint mPaint;

    /**
     * 圆的宽度
     */
    private int mCircleWidth = 10;

    public ArcView(Context context) {
        this(context, null);
    }

    public ArcView(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public ArcView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        mPaint = new Paint();
    }

    @Override
    protected void onDraw(Canvas canvas) {
        mPaint.setAntiAlias(true);//取消锯齿
        mPaint.setStyle(Paint.Style.FILL);
        mPaint.setStrokeWidth(mCircleWidth);
        mPaint.setColor(Color.parseColor("#ffffff"));

        /**
         * 这是一个居中的圆
         */
//        float x = (getWidth() - getHeight() / 2) / 2;
//        float y = getHeight() / 4;
//
//        RectF oval = new RectF(x, y,
//                getWidth() - x, getHeight() - y);

        int conres = getWidth() / 2;
        int he = getHeight() / 2;
        canvas.drawCircle(conres, he, conres, mPaint);
//        canvas.drawArc(oval, 360, 140, true, mPaint);
    }
}
